home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / CPU.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-15  |  2KB  |  77 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 411 of 473
  3. From : Salim Samaha                        1:167/110.0          08 Apr 93  15:55
  4. To   : Giovanni Palmiotto                  1:167/110.0
  5. Subj : Pasal Programming Problems
  6. ────────────────────────────────────────────────────────────────────────────────
  7. I got this routine here a while ago, it works well in detecting the CPU. }
  8.  
  9. {$D-} {$L-}
  10. Program Cpuu;
  11.  
  12. Const
  13.    Cpu :  Array[1..4] of String[5] = ('8086','80286','80386','80486');
  14.    Cpu8086  = 1;
  15.    Cpu80286 =2;
  16.    Cpu80386 = 3;
  17.    Cpu80486 = 4;
  18.  
  19. Function GetCPU_Type: Byte; Assembler;
  20. Asm
  21.  MOV   DX,Cpu8086
  22.  PUSH  SP
  23.  POP   AX
  24.  CMP   SP,AX
  25.  JNE   @OUT
  26.  MOV   DX, Cpu80286
  27.  PUSHF
  28.  
  29.  POP   AX
  30.  OR   AX,4000h
  31.  PUSH  AX
  32.  POPF
  33.  PUSHF
  34.  POP   AX
  35.  TEST  AX,4000h
  36.  JE   @OUT
  37.  MOV DX, Cpu80386
  38.  {"DB 66h" indicates '386 extended instruction}
  39.  DB 66h; MOV   BX, SP      {MOV EBX, ESP}
  40.  DB 66h, 83h, 0E4h, 0FCh   {AND ESP, FFFC}
  41.  DB 66h; PUSHF             {PUSHFD}
  42.  DB 66h; POP AX            {POP EAX}
  43.  DB 66h; MOV   CX, AX      {MOV ECX, EAX}
  44.  DB 66h, 35h, 00h
  45.  DB 00h, 04h, 00           {XOR EAX, 00040000}
  46.  DB 66h; PUSH   AX     {PUSH EAX}
  47.  
  48.  DB 66h; POPF              {POPFD}
  49.  DB 66h; PUSHF             {PUSHFD}
  50.  DB 66h; POP   AX     {POP EAX}
  51.  DB 66h, 25h, 00h
  52.  DB 00h, 04h, 00h          {AND EAX, 00040000}
  53.  DB 66h, 81h, 0E1h, 00h
  54.  DB 00h, 04h, 00h          {AND ECX, 00040000}
  55.  DB 66h; CMP   AX, CX      {CMP EAX, ECX}
  56.  JE @Not486
  57.  MOV DX, Cpu80486
  58. @Not486:
  59.  DB 66h; PUSH   CX         {PUSH EXC}
  60.  DB 66h; POPF              {POPFD}
  61.  DB 66h; MOV   SP, BX      {MOV ESP, EBX}
  62. @Out:
  63.  MOV AX, DX
  64. end;
  65.  
  66. begin
  67.    Writeln; Writeln('I detected an ',Cpu[GetCpu_Type],' chip.');
  68. end.
  69.  
  70. Good luck in finishing your program.
  71.  
  72.                                 SAL
  73.  
  74. --- Maximus/2 2.01wb
  75.  * Origin: Programmer's Quest BBS (1:167/110)
  76.  
  77.